﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using csvm.datamodel.contract;
using NUnit.Framework;
using csvm.recordbuilder.contract;
using csvm.recordbuilder;

namespace csvm.recordbuilder.tests
{
    [TestFixture]
    public class RecortdBuilderTests
    {
        [Test]
        public void Einzelne_Zeile_mit_zwei_Semikolons_wird_in_drei_Spalten_geteilt()
        {
            var sut = new RecordBuilder();

            var input = new List<string>();
            input.Add("col1;col2;col3");
            var result = sut.BuildRecords(input);
    
            Record result1 = result.First();
            Assert.That( result.Count() == 1 );
            Assert.That(result1.Values, Is.EqualTo(new[] {"col1", "col2", "col3"}));
        }

        [Test]
        public void Zwei_Zeilen_mit_je_zwei_Semikolons_werden_in_drei_Spalten_geteilt_Ergebnis_sind_zwei_Records()
        {
            var sut = new RecordBuilder();

            var input = new List<string>();
            input.Add("col1;col2;col3");
            input.Add("1;2;3");
            var result = sut.BuildRecords(input);

            Record result1 = result.First();
            Record result2 = result.ElementAt(1);

            Assert.That(result.Count() == 2);
            Assert.That(result1.Values, Is.EqualTo(new[] { "col1", "col2", "col3" }));
            Assert.That(result2.Values, Is.EqualTo(new[] { "1", "2", "3" }));
        }
         
    }
}
